<div class="layui-tab layui-tab-brief" xmlns:v-on="http://www.w3.org/1999/xhtml"
     xmlns:th="http://www.w3.org/1999/xhtml">
    <ul class="layui-tab-title">
        <li class="layui-this">论坛参数配置</li>
    </ul>
    <div class="layui-tab-content" id="config">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">论坛名称</label>
                <div class="layui-input-block" style="width: 50%">
                    <input type="text" name="name" id="name" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">论坛开关</label>
                <div class="layui-input-block" id="status">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">发帖增分</label>
                <div class="layui-input-block" style="width: 50%">
                    <input type="text" name="postnew" id="postnew" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">评论增分</label>
                <div class="layui-input-block" style="width: 50%">
                    <input type="text" name="commentnew" id="commentnew" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">敏感词设置</label>
                <div class="layui-input-block" style="width: 50%">
                    <textarea name="desc" id="desc" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="demo">保存</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    config.getConfigAll();
</script>
<script>
    layui.use('form', function(){
        var form = layui.form;
        form.render();
    });
</script>
<script>
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(demo)', function(data){
            var da = data.field;
            console.log(da);
            console.log(da.close);
            axios.put('/admin/config/update?parameter='+da.name+'&type=论坛名称')
                .then(function (response) {
                    axios.put('/admin/config/update?parameter='+da.postnew+'&type=发帖增分')
                        .then(function (response) {
                            axios.put('/admin/config/update?parameter='+da.commentnew+'&type=评论增分')
                                .then(function (response) {
                                    axios.put('/admin/config/update?parameter='+da.desc+'&type=敏感词')
                                        .then(function (response) {
                                            if(da.close === undefined){
                                                da.close = "off";
                                            }
                                            axios.put('/admin/config/update?parameter='+da.close+'&type=论坛状态')
                                                .then(function (response) {
                                                    layer.alert('修改成功！');
                                                })
                                                .catch(function (error) {
                                                    layer.alert('修改失败！  '+error);
                                                });
                                        })
                                        .catch(function (error) {
                                            layer.alert('修改失败！  '+error);
                                        });
                                })
                                .catch(function (error) {
                                    layer.alert('修改失败！  '+error);
                                });
                        })
                        .catch(function (error) {
                            layer.alert('修改失败！  '+error);
                        });
                })
                .catch(function (error) {
                    layer.alert('修改失败！  '+error);
                });
            return false;
        });
    });
</script>
